package edu.zut.cs.software.perfect.attendance.service;

import static org.junit.Assert.assertNotNull;

import org.junit.Test;
import org.springframework.beans.factory.annotation.Autowired;

import edu.zut.cs.software.perfect.attendance.domain.AttendanceClerk;
import edu.zut.cs.software.perfect.attendance.domain.CourseAttendance;
import edu.zut.cs.software.perfect.base.service.GenericGenerator;

/**
 * 
 * @Title: AttendanceClerkEntityGenerator
 * @Description: TODO
 * @author: lipengde
 * @date 2020年5月30日 下午4:10:31
 */
public class AttendanceClerkEntityGenerator extends GenericGenerator {

	AttendanceClerkManager attendanceClerkManager;

	CourseAttendanceManager courseAttendanceManager;

	@Autowired
	public void setCourseAttendanceManager(CourseAttendanceManager courseAttendanceManager) {
		this.courseAttendanceManager = courseAttendanceManager;
	}

	@Autowired
	public void setAttendanceClerkManager(AttendanceClerkManager attendanceClerkManager) {
		this.attendanceClerkManager = attendanceClerkManager;
	}

	@Test
	public void testACEG() {
		int num_attendanceClerk = 3;
		int num_courseAttendance = 3;
		for (int i = 0; i < num_attendanceClerk; i++) {
			AttendanceClerk attendanceClerk = new AttendanceClerk();
			attendanceClerk.setCourseCode("Code_" + i);
			attendanceClerk = this.attendanceClerkManager.save(attendanceClerk);
			for (int j = 0; j < num_attendanceClerk; j++) {
				AttendanceClerk c = new AttendanceClerk();
				c.setCourseCode("Code_" + i + "_" + j);
				c.setParent(attendanceClerk);
				c = this.attendanceClerkManager.save(c);
				for (int k = 0; k < num_courseAttendance; k++) {
					CourseAttendance courseAttendance = new CourseAttendance();
					courseAttendance.setCourseCode("Code_" + i + "_" + j + "_" + k);
					courseAttendance.setAttendanceClerk(c);
					courseAttendance = this.courseAttendanceManager.save(courseAttendance);
					assertNotNull(courseAttendance);
				}
			}
		}
	}

}
